<?php
/**
 * $Id: T.php 150 2009-03-03 03:23:17Z hzq $
 *
 */
require_once 'Zend/View/Helper/Abstract.php';


class Plugin_View_Helper_T extends Zend_View_Helper_Abstract
{
    protected static $_lang;
	
    public function t($key,$options = null)
	{
		$locale = array(1=>'zh','en','zh_TW');
		$langID = Langs::getCurrrentLang();
		$langID = $langID?$langID:2;
		
		return $this->view->translate($key,$locale[$langID]);
	}
   
    public function st($key,$options = null)
    {
    	/*$oTranslate = Zend_Registry::get('translate');
    	return $oTranslate->_($key,$options);*/    	
    	
    	$this->loadLang();	
		if(isset($this->_lang[$key])){
			return $this->_lang[$key];
		}else{		
			return $key;
		}
		
    }
    
    protected function loadLang()
    {
	
    	if(isset($this->_lang) && !empty($this->_lang))return $this->_lang;

		$idtofile = array(1=>'zh-cn','en','zh');
		$langID = Langs::getCurrrentLang();

		
		$langID = $langID?$langID:2;		
		if(!isset($this->_lang) or empty($this->_lang)){				
			$this->_lang = include ROOT_DIR.'/app/languages/default/'.$idtofile[$langID].'.php';
		}
		
		return true;

    }
    
}
